Newtouch.CascadeSelect = {
    cascade : function(id, value, callback) {
		var childId = document["_nt-cs_-childId:" + id];
		$("#__"+childId+"__loading").show();
		if (childId == undefined) {
		    return;
		}
		this.clearChild(childId);
	
		var action = document['_nt-cs_-id:' + childId + '-action'];
		var params = document['_nt-cs_-id:' + childId + '-params'];
		var textField = document['_nt-cs_-id:' + childId + '-text'];
		var valueField = document['_nt-cs_-id:' + childId + '-value'];
		var defaultValue = document['_nt-cs_-id:'+ childId + '-defaultValue'];
		params.value = value;
		if(value==null||value==""){
			$("#__"+childId+"__loading").hide();
			return;
		}
		$("#"+id).attr("disabled",true);
		Newtouch.Ajax.sendParams(params, action, function(result) {
		    $("#__"+childId+"__loading").hide();
		    if (result && result.length > 0) {
			for ( var i = 0; i < result.length; i++) {
			    $('#' + childId)[0].options.add(new Option(result[i][textField], result[i][valueField]))
			}
			$('#' + childId).val(defaultValue);
		    }
		    $("#"+id).attr("disabled","");
		    if(callback){
				callback($("#"+id));
			}
		}, function(result) {
			$("#"+id).attr("disabled","");
		    alert(result);
		});
    },
    clearChild : function(childId) {
		//清理下级
	    if (childId) {
			$('#' + childId)[0].options.length = 1;
	    }
	    //需要递归重置子select为空集合	
	    if (typeof document["_nt-cs_-childId:" + childId] != "undefined" && document["_nt-cs_-childId:" + childId]) {
			this.clearChild(document["_nt-cs_-childId:" + childId]);
	    }else{
	    	$('#' + childId)[0].options.selectedIndex = 0;
	    }
	}
}